/*  1:   */ package org.jetbrains.jps.model.serialization.facet;
/*  2:   */ 
/*  3:   */

import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsElement;
import org.jetbrains.jps.model.JpsElementChildRole;
import org.jetbrains.jps.model.module.JpsModule;

import java.util.List;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */ 
/* 12:   */ public abstract class JpsFacetConfigurationSerializer<E extends JpsElement>
/* 13:   */ {
/* 14:   */   private final JpsElementChildRole<E> a;
/* 15:   */   private final String b;
/* 16:   */   private final String c;
/* 17:   */   
/* 18:   */   public JpsFacetConfigurationSerializer(JpsElementChildRole<E> paramJpsElementChildRole, String paramString1, @Nullable String paramString2)
/* 19:   */   {
/* 20:36 */     this.a = paramJpsElementChildRole;
/* 21:37 */     this.b = paramString1;
/* 22:38 */     this.c = paramString2;
/* 23:   */   }
/* 24:   */   
/* 25:   */   public String getFacetTypeId()
/* 26:   */   {
/* 27:42 */     return this.b;
/* 28:   */   }
/* 29:   */   
/* 30:   */   public E loadExtension(Element paramElement, String paramString, JpsModule paramJpsModule, JpsElement paramJpsElement)
/* 31:   */   {
/* 32:46 */     JpsElement localJpsElement = loadExtension(paramElement, paramString, paramJpsElement, paramJpsModule);
/* 33:47 */     return paramJpsModule.getContainer().setChild(this.a, localJpsElement);
/* 34:   */   }
/* 35:   */   
/* 36:   */   protected abstract E loadExtension(@NotNull Element paramElement, String paramString, JpsElement paramJpsElement, JpsModule paramJpsModule);
/* 37:   */   
/* 38:   */   public boolean hasExtension(JpsModule paramJpsModule)
/* 39:   */   {
/* 40:53 */     return paramJpsModule.getContainer().getChild(this.a) != null;
/* 41:   */   }
/* 42:   */   
/* 43:   */   public void saveExtension(JpsModule paramJpsModule, @NotNull List<FacetState> paramList)
/* 44:   */   {
/* 45:57 */     if (paramList == null) {
/* 46:57 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/jps/model/serialization/facet/JpsFacetConfigurationSerializer", "saveExtension" }));
/* 47:   */     }
/* 48:57 */     JpsElement localJpsElement = paramJpsModule.getContainer().getChild(this.a);
/* 49:58 */     if (localJpsElement != null)
/* 50:   */     {
/* 51:59 */       FacetState localFacetState = new FacetState();
/* 52:60 */       localFacetState.setFacetType(this.b);
/* 53:61 */       localFacetState.setName(this.c);
/* 54:62 */       Element localElement = new Element("configuration");
/* 55:63 */       saveExtension(localJpsElement, localElement, paramJpsModule);
/* 56:64 */       localFacetState.setConfiguration(localElement);
/* 57:65 */       paramList.add(localFacetState);
/* 58:   */     }
/* 59:   */   }
/* 60:   */   
/* 61:   */   protected abstract void saveExtension(E paramE, Element paramElement, JpsModule paramJpsModule);
/* 62:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.jps.model.serialization.facet.JpsFacetConfigurationSerializer

 * JD-Core Version:    0.7.0.1

 */